﻿using System;
using System.Windows.Forms;

namespace QWManage.Forms
{
    public partial class FrmTimerSetting : Form
    {
        public FrmTimerSetting()
        {
            InitializeComponent();
        }

        private void FrmTimerSetting_Load(object sender, EventArgs e)
        {
            //cmbHour.DropDownStyle = ComboBoxStyle.DropDownList;
            //cmbHourStart.DropDownStyle = ComboBoxStyle.DropDownList;
            //cmbHourEnd.DropDownStyle = ComboBoxStyle.DropDownList;
            //for (int hour = 0; hour <= 23; hour++)
            //{
            //    cmbHour.Items.Add(hour.ToString("00时"));
            //    cmbHourStart.Items.Add(hour.ToString("00时"));
            //    cmbHourEnd.Items.Add(hour.ToString("00时"));
            //}
            //cmbMinute.DropDownStyle = ComboBoxStyle.DropDownList;
            //cmbMinuteStart.DropDownStyle = ComboBoxStyle.DropDownList;
            //cmbMinuteEnd.DropDownStyle = ComboBoxStyle.DropDownList;
            //for (int minute = 0; minute <= 59; minute++)
            //{
            //    cmbMinute.Items.Add(minute.ToString("00分"));
            //    cmbMinuteStart.Items.Add(minute.ToString("00分"));
            //    cmbMinuteEnd.Items.Add(minute.ToString("00分"));
            //}

            //AppTimerInfo appTimer = AppTimerMgr.Get();
            //chbDaily.Checked = appTimer.Daily;
            //cmbGroups.Checked = appTimer.Groups;

            //cmbHour.Enabled = chbDaily.Checked;
            //cmbMinute.Enabled = chbDaily.Checked;

            //cmbHourStart.Enabled = cmbGroups.Checked;
            //cmbMinuteStart.Enabled = cmbGroups.Checked;
            //cmbHourEnd.Enabled = cmbGroups.Checked;
            //cmbMinuteEnd.Enabled = cmbGroups.Checked;

            //cmbHour.Text = appTimer.Hour.ToString("00时");
            //cmbHourStart.Text = appTimer.HourStart.ToString("00时");
            //cmbHourEnd.Text = appTimer.HourEnd.ToString("00时");


            //cmbMinute.Text = appTimer.Minute.ToString("00分");
            //cmbMinuteStart.Text = appTimer.MinuteStart.ToString("00分");
            //cmbMinuteEnd.Text = appTimer.MinuteEnd.ToString("00分");


        }



        private void ComboBoxes_CheckedChanged(object sender, EventArgs e)
        {
            //cmbHour.Enabled = chbDaily.Checked;
            //cmbMinute.Enabled = chbDaily.Checked;

            //cmbHourStart.Enabled = cmbGroups.Checked;
            //cmbMinuteStart.Enabled = cmbGroups.Checked;
            //cmbHourEnd.Enabled = cmbGroups.Checked;
            //cmbMinuteEnd.Enabled = cmbGroups.Checked;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            //AppTimerInfo appTimer = new AppTimerInfo();
            //appTimer.Daily = chbDaily.Checked;
            //appTimer.Hour = Convert.ToInt32(cmbHour.Text.TrimEnd('时'));
            //appTimer.Minute = Convert.ToInt32(cmbMinute.Text.TrimEnd('分'));

            //appTimer.Groups = cmbGroups.Checked;
            //appTimer.HourStart = Convert.ToInt32(cmbHourStart.Text.TrimEnd('时'));
            //appTimer.MinuteStart = Convert.ToInt32(cmbMinuteStart.Text.TrimEnd('分'));

            //appTimer.HourEnd = Convert.ToInt32(cmbHourEnd.Text.TrimEnd('时'));
            //appTimer.MinuteEnd = Convert.ToInt32(cmbMinuteEnd.Text.TrimEnd('分'));

            //if (appTimer.Groups)
            //{
            //    int min = Convert.ToInt32(appTimer.HourStart.ToString("00") + appTimer.MinuteStart.ToString("00"));
            //    int max = Convert.ToInt32(appTimer.HourEnd.ToString("00") + appTimer.MinuteEnd.ToString("00"));
            //    if (min >= max)
            //    {
            //        Common.MessageBoxWarning("起始时间要小于结束时间");
            //        return;
            //    }
            //}
            //AppTimerMgr.Set(appTimer);
            //DialogResult = DialogResult.OK;
        }
    }
}
